﻿using MicroOrm.Pocos.SqlGenerator.Attributes;
using Microsoft.AspNet.Identity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WebMvc.Models
{
    [StoredAs("ApplicationUser")]
    public class ApplicationUser : IUser<string>
    {
        public string Id
        {
            get
            {
                return DateTime.Now.ToString("yyyyMMddHHmmsssffff");
            }
            set { }
        }

        public string UserName
        {
            get; set;
        }


        public string PassWord { get; set; }

        public DateTime CreateOn { get; set; }

        public virtual ICollection<ApplicationRole> Roles { get; private set; }

        public ApplicationUser() { this.CreateOn = DateTime.Now; Roles = new List<ApplicationRole>();   }
    }

    [StoredAs("ApplicationRole")]
    public class ApplicationRole : IRole<string>
    {
        public string Id
        {
            get
            {
                return System.Guid.NewGuid().ToString();
            }
            set { }
        }

        public string Name
        {
            get; set;
        }
        public string Remarks { get; set; }
        public DateTime CreateOn { get; set; }
         
        /// <summary>
        ///     Navigation property for users in the role
        /// </summary>
        public virtual ICollection<ApplicationUserRoles> Users { get; private set; }

        /// <summary>
        ///  Constructor
        /// </summary>
        public ApplicationRole() { CreateOn = DateTime.Now; Users = new List<ApplicationUserRoles>(); }
    }

    public class ApplicationUserRoles 
    {
        /// <summary>
     ///     UserId for the user that is in the role
     /// </summary>
        public virtual string UserId { get; set; }

        /// <summary>
        ///     RoleId for the role
        /// </summary>
        public virtual string RoleId { get; set; }

    }
}
